#include <stdio.h>
int main()
{
    int a,b,n,t,i;
    scanf("%d",&n);
    while (n--)
    {
        scanf("%d%d",&a,&b);
        t=0;
        for (i=1;i<=a/2;i++)if (a%i==0)t+=i;
        if (t!=b)printf("NO\n");
        else
        {
            t=0;
            for (i=1;i<=b/2;i++)if (b%i==0)t+=i;
            if (t!=a)printf("NO\n");
            else printf("YES\n");
        }
    }
    return 0;
}
